package training;

/**
 * 裁判类
 */
public class Judge {
    private Player player = new Player(100);
    private Computer computer = new Computer(100);
    public void check(){
        while(true){
            int playerValue = player.send();
            int computerValue = computer.send();
            System.out.println("电脑出拳：" + computerValue);
            if(playerValue > computerValue){
                if(playerValue - computerValue == 2){
                    System.out.println("电脑赢");
                    player.setScore(player.getScore() - 1);
                    computer.setScore(computer.getScore() + 1);
                }else{
                    System.out.println("玩家赢");
                    player.setScore(player.getScore() + 1);
                    computer.setScore(computer.getScore() - 1);
                }
            }else if(computerValue > playerValue){
                if(computerValue - playerValue == 2){
                    System.out.println("玩家赢");
                    player.setScore(player.getScore() + 1);
                    computer.setScore(computer.getScore() - 1);
                }else{
                    System.out.println("电脑赢");
                    player.setScore(player.getScore() - 1);
                    computer.setScore(computer.getScore() + 1);
                }
            }else{
                System.out.println("平局");
            }
            System.out.println("电脑分数："+computer.getScore()+"\n玩家分数："+player.getScore());
        }

    }

    public static void main(String[] args) {
        Judge judge = new Judge();
        judge.check();
    }
}
